<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ include file="../common/taglibs.jsp"%>
<%
    String path = request.getContextPath();
			String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
					+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="${rootPath}/css/common.css" type="text/css" rel="stylesheet" />
<title>终端序列号归属查询</title>
<script type="text/javascript"
	src="<s:url value="/js/jquery-1.3.2.js" />"></script>
<script type="text/javascript" src="<s:url value="/js/common.js" />"></script>
<script language="javascript" type="text/javascript"
	src="<s:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
<script type='text/javascript' src='<s:url value="/dwr/engine.js"/>'></script>
<script type='text/javascript'
	src='<s:url value="/dwr/interface/MccQuery.js"/>'></script>
<script type="text/javascript">
	$(document).ready(function() {

		loadBrandCode();
	});

	//加载终端名称
	function loadBrandCode() {

		var sortCode = $("#posBrand").val();
		var posName = $("#posName").val();
		if (sortCode == null || sortCode == "-1") {
			//$("#posName").empty().append("<option value='-1'>请选择</option>");
			return;
		}

		MccQuery.loadBrandNameByCode(sortCode, function(sortSmall) {

			fillSelect_sort("posName", sortSmall, posName);

		});
	}

	function fillSelect_sort(sid, address, choiseId) {

		if (!address || !sid) {
			return;
		}

		var $select = $("#" + sid);
		$select.empty();

		$("#" + sid).empty().append("<option value='-1'>--请选择--</option>");

		for (var i = 0; i < address.length; i++) {
			$select.append("<option value='"+address[i].CODE+"'>"
					+ address[i].NAME + "</option>");
		}

		if (choiseId != "" && choiseId != null) {
			$("#" + sid).val(choiseId);
		}
	}
</script>
</head>
<body>
		<s:form id="queryUserForm" action="/termSn/termSnBelongSearch.ct"
			method="post" theme="simple">
			<s:hidden name="posInfo.agentId"></s:hidden>
		<table class="tb">
			<tr class="tb-line">
            	<td class="tb-td" colspan="6"><div class="tb-h2">POS收单运营管理平台</div><font color="red">提示：终端品牌、型号后台规整中</font> </td>
       		</tr>
			<tr class="tb-line">
            	<td class="tb-td" colspan="6"><div class="tb-h3">终端序列号归属查询</div></td>
        	</tr>
		    <tr class="tb-line">
	            <td width="12%" style="min-width: 150px" align="right" class="tb-td">
	                <div class="tb-h4">品牌：</div>
	            </td>
				<td class="tb-td">
					<label class="tb-select">
						<s:select cssClass="queryWidth"
							name="searchCondition.posBrand" id="posBrand"
							onchange="loadBrandCode()" list="#request.brandMap" listKey="key"
							listValue="value" headerKey="-1" headerValue="--请选择--" />
					</label>
			    </td>

				<td width="12%" style="min-width: 150px" align="right" class="tb-td">
                	<div class="tb-h4">型号：</div>
            	</td>
				<td class="tb-td">
					<label class="tb-select">
						<s:select cssClass="queryWidth"
							name="searchCondition.posName" id="posName"
							list="#request.nameMap" listKey="key" listValue="value"
							headerKey="-1" headerValue="--请选择--" />
					</label>
				</td>

				<td width="12%" style="min-width: 150px" align="right" class="tb-td">
                	<div class="tb-h4">类型：</div>
           	    </td>
				<td class="tb-td">
					<label class="tb-select">
						<s:select cssClass="queryWidth"
								name="searchCondition.posType" id="posType"
								list="#request.typeMap" listKey="key" listValue="value"
								headerKey="-1" headerValue="--请选择--" />
					</label>
				</td>
			</tr>
			<tr class="tb-line">
				<td align="right" class="tb-td">
                	<div class="tb-h4">是否已出库：</div>
            	</td> 
				<td class="tb-td">
                	<label class="tb-select">
						<s:select name="searchCondition.isUsed"
								list="#{'N':'否','Y':'是'}" headerKey="-1" headerValue="-请选择---"
								cssClass="queryWidth"></s:select>
				      </label>
           		</td>
	            <td align="right" class="tb-td">
	                <div class="tb-h4">终端序列号：</div>
	            </td>
	            <td class="tb-td">
	            	<label class="tb-input-normal">
						<s:textfield id="serialNum"
								name="searchCondition.serialNum" cssClass="queryWidth" />
					</label>	
				</td>
				<s:if
					test="#session.session_merchant.roleType==\"03\"||#session.session_merchant.roleType==\"15\" || #session.session_merchant.roleType==\"16\"">
					<td align="right" class="tb-td">
            		</td>
					<td>
							<s:hidden name="searchCondition.orgCode"
									value="%{#session.session_merchant.orgCode}" />
					</td>
				</s:if>
				<s:else>
					<td align="right" class="tb-td">
               			 <div class="tb-h4">所属机构：</div>
            		</td>
					<td class="tb-td">
                		<label class="tb-select">
							<s:select cssClass="queryWidth"
									name="searchCondition.orgCode" id="orgCode"
									list="#request.orgList" listKey="InsIdCd" listValue="InsName" />
						</label>
					</td>
				</s:else>

			</tr>
			<tr class="tb-line">
	            <td class="tb-td line-submit" align="right" colspan="6">
	                <label class="tb-input-submit">
						<s:submit value="查 询" id="sub" />
					</label>
					<label class="tb-input-submit">
						<s:reset value="取  消" />
					</label>
				</td>
			</tr>
			<tr class="tb-line" >
				<td class="tb-td" colspan="6" align="center">
					<div style="color: red;">
						<s:actionmessage />
					</div>
					<div style="color: red;">
						<s:actionerror />
					</div>
				</td>
			</tr>
		</table>
		<div class="big-tb">
		    <table class="tb" style="width: 130%;">
		        <thead>
		        	<tr class="tb-line">
                		<th class="tb-th" colspan="12">终端序列号信息列表</th>
          			</tr>
          			<s:if test="#request.searchRsList != null && #request.searchRsList.size>0">
						<tr class="tb-line">
							<td class="tb-td paging" align="left" colspan="12">
								<page:pageCount
									max_pages="11" totalPage="${requestScope.totalPage}"
									currentPage="${requestScope.currentPage}"
									action="${rootPath}/termSn/termSnBelongSearch.ct?currentPage=" />
							</td>
						</tr>
					</s:if>
					<tr class="tb-line bg-gray">

						<th class="tb-th">终端序列号</th>
						<th class="tb-th">所属代理商</th>
						<th class="tb-th">是否已出库</th>
						<th class="tb-th">是否已绑定</th>
						<th class="tb-th">商户号</th>
						<th class="tb-th">终端号</th>
						<th class="tb-th">品牌</th>
						<th class="tb-th">型号</th>
						<th class="tb-th">类型</th>

						<th class="tb-th">入库时间</th>
						<th class="tb-th">出库时间</th>
						<th class="tb-th">备注</th>
					</tr>
				</thead>
				<tbody>
					<s:iterator value="#request.searchRsList" status="stat" id="term">
						<%-- <tr class="<s:if test="#stat.index%2==0">tr_0</s:if>"> --%>
						<tr class="tb-line">
							<td class="tb-td">
								<s:property value="#term.serialNum" />
							</td>
							<td class="tb-td">
								<s:property value="#term.agentName" />
							</td>
							<td class="tb-td">
								<s:if test="#term.isUsed==\"N\"">否</s:if> <s:else>是</s:else>
							</td>
							<td class="tb-td">
								<s:if test="#term.isBind==\"N\"">否</s:if> <s:else>是</s:else>
							</td>
							<td class="tb-td">
								<s:property value="#term.mercCode" />
							</td>
							<td class="tb-td">
								<s:property value="#term.termCode" />
							</td>
							<td class="tb-td">
								<s:property value="#term.posBrand" />
							</td>
							<td class="tb-td">
								<s:property value="#term.posName" />
							</td>
							<td class="tb-td">
								<s:property value="#term.posType" />
							</td>
							<td class="tb-td">
								<s:property value="#term.dtCreate" />
							</td>
							<td class="tb-td">
								<s:property value="#term.dtLostmod" />
							</td>
							<td class="tb-td">
								<s:property value="#term.remark" />
							</td>
						</tr>
					</s:iterator>
				</tbody>
			</table>
		</div>
		</s:form>
</body>
</html>